import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_250303/pages/home/home_page.dart';
import 'package:flutter_250303/pages/hot_key/hot_key_page.dart';
import 'package:flutter_250303/pages/knowledge/knowledge_page.dart';
import 'package:flutter_250303/pages/personal/personal_page.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class TabPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _TabPageState();
  }
}

class _TabPageState extends State<TabPage> {
  int currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: IndexedStack(
          index: currentIndex,
          children: [HomePage(), HotKeyPage(), KnowledgePage(), PersonalPage()],
        ),
      ),
      bottomNavigationBar: Theme(
        data: Theme.of(context).copyWith(
            splashColor: Colors.transparent, highlightColor: Colors.blue),
        child: BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          selectedLabelStyle: TextStyle(fontSize: 14, color: Colors.black),
          unselectedLabelStyle: TextStyle(fontSize: 14, color: Colors.blue),
          items: _barItemList(),
          currentIndex: currentIndex,
          onTap: (index) {
            currentIndex = index;
            setState(() {});
          },
        ),
      ),
    );
  }

  List<BottomNavigationBarItem> _barItemList() {
    BottomNavigationBarItem item1 = BottomNavigationBarItem(
      label: "首页",
      icon: Image.asset(
        "assets/images/bee.png",
        width: 30.r,
        height: 30.r,
        fit: BoxFit.fill,
      ),
      // activeIcon:
    );
    BottomNavigationBarItem item2 = BottomNavigationBarItem(
      label: "热点",
      icon: Image.asset(
        "assets/images/bee.png",
        width: 30.r,
        height: 30.r,
        fit: BoxFit.fill,
      ),
    );
    BottomNavigationBarItem item3 = BottomNavigationBarItem(
      label: "体系",
      icon: Image.asset(
        "assets/images/bee.png",
        width: 30.r,
        height: 30.r,
        fit: BoxFit.fill,
      ),
    );
    BottomNavigationBarItem item4 = BottomNavigationBarItem(
      label: "我的",
      icon: Image.asset(
        "assets/images/bee.png",
        width: 30.r,
        height: 30.r,
        fit: BoxFit.fill,
      ),
    );

    return [item1, item2, item3, item4];
  }
}
